#define _CRT_SECURE_NO_WARNINGS 
#include <stdio.h>

void quick_sort(int* arr, int arrSize)
{
	int i = 0, j = 0;

	for ( i = 1, j = 0; i < arrSize; i++)
	{
		if (arr[i] < arr[0])
		{
			j++;
			if (j != i)
			{
				int tmp = arr[i];
				arr[i] = arr[j];
				arr[j] = tmp;
			}
		}
	}
	for (i = 0; i < arrSize; i++)
	{
		printf("%d ", arr[i]);
	}
	printf("\n");

	if (j != 0)
	{
		arr[0] = arr[0] + arr[j];
		arr[j] = arr[0] - arr[j];
		arr[0] = arr[0] - arr[j];
		quick_sort(arr, j);
	}
	if (arrSize - j - 1 > 1)
		quick_sort(arr + j + 1, arrSize - j - 1);
	
}









int main()
{
	int arr[16] = { 35,62,69,8,7,3,6,1,93,16,31,51,26,316,94,77 };

	quick_sort(arr, sizeof(arr)/sizeof(arr[0]));

	for (int i = 0; i < sizeof(arr)/sizeof(arr[0]); i++)
	{
		printf("%d, ", arr[i]);
	}
	printf("\n");
	return 0;
}
